<template>
    <div class="pohotoslist">
       <!-- //图片列表滑块  -->
      <div id="slider" class="mui-slider">
        
            <div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
               <!-- 启用scroll区域滑动  -->
                <div class="mui-scroll">
                    <!-- 判断点击的图片标题是否为id为0 为0 加类mui-active' 默认选中 -->
                    <!-- @tap 绑定移动端点击事件  在移动端比click 少300ms的延迟-->
                    <a  :class="['mui-control-item',item.id ===0?'mui-active':'']" 
                     v-for="item in imgcategoryList" :key="item.id"  @tap="getimages(item.id)"
                     data-wid="tab-top-subpage-1.html" >
                       {{item.title}}
                    </a>
                </div>
            </div>
        </div>
       <!-- 图片列表详情 -->
    <div class="cateImages">
        <ul>
            <router-link  v-for="item in getimagesList" :key="item.id"  tag="li" :to="'/pohotos/pohotoinfo/'+item.id">
                <!-- v-lazy 图片懒加载 需要npm 安装插件 cnpm i vue-lazyload -S  main全局注册-->
                <img v-lazy="item.img_url"  loading>
                <div class="info">
                    <div class="title">
                        {{item.title}}
                    </div>
                    <div class="content">
                        {{item.zhaiyao}}
                    </div>
                </div>
            </router-link>
        </ul>
    </div>
    </div>
</template>
<script>
    import mui from '../../../static/mui/js/mui.min.js'
    export default {
        data() {
            return {
                imgcategoryList: [],
                getimagesList: []
            }
        },
        mounted() {
            //设置图片标题滑块 
            //初始化scroll控件
            mui(".mui-scroll-wrapper").scroll({
                deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
            })
        },
        created() {
            this.getimgcategory()
            this.getimages(0)
        },
        methods: {
            //获取图片标题数据
            async getimgcategory() {
                const {
                    data
                } = await this.$http.get('api/getimgcategory')

                if (data.status === 0) {
                    data.message.unshift({
                        id: 0,
                        title: "全部"
                    })
                    this.imgcategoryList = data.message
                }

            },
            //获取图片
            async getimages(id) {
                const {
                    data
                } = await this.$http.get('api/getimages/' + id)
                if (data.status === 0) this.getimagesList = data.message
                console.log(data.message);

            }
        },
    }
</script>
<style lang="scss" scoped>
    .pohotoslist {
        .cateImages {
            list-style: none;
            padding: 10px;
            margin: 0;
            padding-bottom: 0;
            li {
                background-color: #ccc;
                margin-bottom: 10px;
                box-shadow: 0 0 9px #999;
                position: relative;
                img {
                    width: 100%;
                    min-height: 355px;
                    /* 解决图片3像素 */
                    vertical-align: middle;
                }
                img[lazy="loading"] {
                    width: 40px;
                    height: 100px;
                    margin: auto;
                }
                .info {
                    position: absolute;
                    bottom: 0;
                    background-color: rgba(0, 0, 0, 0.4);
                    color: #fff;
                    text-align: left;
                    min-height: 84px;
                    .title {
                        font-size: 14px;
                    }
                    .content {
                        font-size: 12px;
                    }
                }
            }
        }
    }
</style>